﻿#ifndef SYSTEMMONITORMANAGER_H
#define SYSTEMMONITORMANAGER_H

#include <QObject>
#include <QMutex>
#include "common.h"
#include "Logger.h"

#include "syscpumonitor.h"
#include "sysmemmonitor.h"
#include "sysdiskmonitor.h"

#define CPU_USAGE_MAX_DISPLAY_COUNT 20
#define MEM_USAGE_MAX_DISPLAY_COUNT 20

class SystemMonitorManager : public QObject
{
     Q_OBJECT

public:
    SystemMonitorManager();

    void startAllTask();

    void stopAllTask();

    void restartCPUTask();

    void restartDiskTask();

    void restartMemoryTask();

    void updateCurrentDiskUsage(list<DiskInfo> & usage);

    void updateCurrentMemUsage(MEMORYSTATUSEX memStatus);

    void updateCurrentCpuUsage(double cpuUsage);



signals:

    void onSysMonitorAlarmFired();

    void diskUsageUpdated();

    void memUsageUpdated();

    void cpuUsageUpdated();
public:

    SysCPUMonitor* cpuMonitor;

    SysMEMMonitor* memMointor;

    SysDiskMonitor* diskMonitor;

    list<DiskInfo> lastDiskInfo;
    
    list<double> lastCPUUsages;
    
    list<MEMORYSTATUSEX> lastMEMUsages;

    QMutex lock;

};

extern SystemMonitorManager gSystemMonitorManger;
#endif // SYSTEMMONITORMANAGER_H
